<template>

  <div>
    <data-table
      ref="pagingTable"
      :options="options"
      :list-query="listQuery"
    >
      <template slot="filter-content">

        <el-input v-model="listQuery.params.no" placeholder="搜索证书编号" style="width: 200px;" class="filter-item" />
        <el-input v-model="listQuery.params.name" placeholder="搜索姓名" style="width: 200px;" class="filter-item" />
      </template>

      <template slot="data-columns">

        <el-table-column
          label="证书编号"
          prop="no"
          show-overflow-tooltip
        />
        <el-table-column
          label="类型"
          prop="type"
          show-overflow-tooltip
        />
        <el-table-column
          label="姓名"
          prop="name"
          align="center"
        />
        <el-table-column
          label="性别"
          prop="sex"
          align="center"
        />
        <el-table-column
          label="身份证"
          prop="idNo"
          align="center"
        />

<!--        <el-table-column
          label="操作"
          align="center"
        >
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="handleGrant(scope.row.no, scope.row.realName, scope.row.sex, scope.row.idNo,scope.row.title.split(' ')[0])">颁发</el-button>
          </template>

        </el-table-column>-->

      </template>

    </data-table>

    <el-dialog title="考试明细" :visible.sync="dialogVisible" width="60%">

      <div class="el-dialog-div">
        <my-paper-list :exam-id="examId" :user-id="userId" />
      </div>

    </el-dialog>

  </div>

</template>

<script>
import DataTable from '@/components/DataTable'
import { mapGetters } from 'vuex'
import { saveData } from '@/api/ca/ca'
export default {
  name: 'MyExamList',
  components: { DataTable },
  data() {
    return {

      dialogVisible: false,
      examId: '',

      listQuery: {
        current: 1,
        size: 10,
        params: {
          title: ''
        }
      },

      options: {
        // 可批量操作
        multi: false,
        // 列表请求URL
        listUrl: '/ca/api/manage/paging'
      }
    }
  },
  computed: {
    ...mapGetters([
      'userId'
    ])
  },
  methods: {

    // 颁发
    handleGrant(no, name, sex, idNo, type) {
      const data = { no: no, name: name, sex: sex, idNo: idNo, type: type }
      console.log(data)
      saveData(data).then(() => {
        this.$message({
          type: 'success',
          message: '颁发成功!'
        })
        this.$refs.pagingTable.getList()
      })
    }
  }
}
</script>

<style scoped>

  .el-dialog-div{
    height: 60vh;
    overflow: auto;
    padding: 10px;
  }

</style>
